package controllClient;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import controllBen.Leitor;
import controllServer.LeitorControll;

/**
 * Servlet implementation class LoginServlet
 */
public class LoginServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	private LeitorControll controll;
	
    public LoginServlet() {
        super();
    
        try {
			controll = new LeitorControll();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		Leitor leitor = new Leitor();
				
		String log = request.getParameter("login");
		String senh = request.getParameter("senha");
		
		System.out.println(log + " " + senh);
		
		leitor = controll.getLoginSenha(log, senh);
		
		request.getSession().setAttribute("Leitor", leitor);
		request.getRequestDispatcher("index.jsp").forward(request, response);
	}

}
